<?php
/**
 * ============================================================================
 * 版权所有 2008-2011 多多网络，并保留所有权利。
 * 网站地址: http://soft.duoduo123.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
session_start();
error_reporting(0);
include_once 'comm/config.php';
include_once 'comm/Taoapi.php';
include_once 'comm/page.class.php';
include_once 'comm/checkpostandget.php';

$iid=$_GET['iid'];
$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');

$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.taobaoke.items.detail.get';
$Taoapi->nick = MYUSERNICK;
$Taoapi->num_iids = $iid;
$Taoapi->outer_code=$_SESSION["dduserid"];
$Taoapi->fields = 'iid,detail_url,num_iid,title,nick,type,cid,desc,pic_url,num,list_time,delist_time,stuff_status,location,price,post_fee,express_fee,ems_fee,has_discount,freight_payer,seller_credit_score,shop_click_url,click_url,volume,stuff_status,has_invoice,cid,auction_point';
$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();

$titles = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["title"]; 
$type = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["type"]; 
$cid = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["cid"]; 
$sellernick = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["nick"]; 
$usernick=$sellernick;
$post_fee = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["post_fee"]; 
$express_fee = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["express_fee"]; 
$ems_fee = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["ems_fee"]; 
$desc = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["desc"]; 
$num = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["num"]; 
$price = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["price"]; 
$pic_path = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["pic_url"]; 
$list_time = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["list_time"]; 
$delist_time = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["delist_time"]; 
$freight_payer = $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["freight_payer"]; 
$stuff_status= $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["stuff_status"]; 
$has_invoice= $TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["has_invoice"]; 
$volume=$TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["volume"]; 
$state=$TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["location"]["state"]; 
$city=$TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["location"]["city"]; 
$cid=$TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["item"]["cid"]; 
$shop_click_url=$TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["shop_click_url"]; 
$click_url=$TaobaokeData["taobaoke_item_details"]["taobaoke_item_detail"]["click_url"]; 
if($freight_payer=="seller"){$freight_payer="卖家承担";}else{$freight_payer="买家承担";}
$desc=preg_replace("/(?<=href=)([^\>]*)(?=\>)/i","#", $desc);

if($titles==''){
 echo ERR403;
 exit;
}
//获取该商品的返现金额
$Taoapi->method = 'taobao.taobaoke.items.convert';
$Taoapi->fields = 'commission';
$Taoapi->nick =  MYUSERNICK;
$Taoapi->num_iids=$iid;
$CommData = $Taoapi->Send('get','xml')->getArrayData();
$ThisComm=ck_fxje($CommData['taobaoke_items']['taobaoke_item']['commission'],$_SESSION["dduserlevel"]);

//获取掌柜基本信息
$Taoapi->method = 'taobao.user.get';
$Taoapi->fields = 'user_id,nick,consumer_protection,seller_credit,location,type';
$Taoapi->nick = $sellernick;
$TaoapiUsers = $Taoapi->Send('get','xml')->getArrayData();
$Result_users = $TaoapiUsers["user"];
$uid=$Result_users["user_id"];
$shoptype=$Result_users["type"];
$shoplevel=$Result_users["seller_credit"]["level"];
$consumer_protection=$Result_users["consumer_protection"];
$shopstate=$Result_users["location"]["state"];
$shopcity=$Result_users["location"]["city"];
//采集店铺信息
$sql="select * from ".$BIAOTOU."shop where nick='".$sellernick."'";
$rsnum = mysql_query($sql);
$totalu=mysql_num_rows($rsnum);

if($totalu==0){
		//获取店铺基本信息
		$Taoapi->method = 'taobao.shop.get';
		$Taoapi->fields = 'sid,cid,title,desc,pic_path,created,shop_score';
		$Taoapi->nick = $sellernick;
		$ShopData = $Taoapi->Send('get','xml')->getArrayData();
		$Result_shop=$ShopData['shop'];
		$shoppic=$Result_shop['pic_path'];
		$sid=$Result_shop['sid'];
		$item_score=$Result_shop["shop_score"]["item_score"];
		$service_score=$Result_shop["shop_score"]["service_score"];
		$delivery_score=$Result_shop["shop_score"]["delivery_score"];
		$shopcreated=$Result_shop['created'];
		$shoptitle=$Result_shop['title'];
		if((SHOPCJ=='1')&&(($shoplevel>=SHOPCJS)&&($shoplevel<=SHOPCJE))){
			//获取店铺平均返现率
			$Taoapi->method = 'taobao.taobaoke.shops.convert';
			$Taoapi->fields = 'commission_rate';
			$Taoapi->sids = $sid;
			$Taoapi->nick = MYUSERNICK;
			$ShopComm = $Taoapi->Send('get','xml')->getArrayData();
			$Result_shopcomm=$ShopComm['taobaoke_shops']['taobaoke_shop']['commission_rate'];
			$fanxianlv=$Result_shopcomm;
			$good=round($Result_users["seller_credit"]["good_num"]/$Result_users["seller_credit"]["total_num"]*100,2);
			$sql="insert into ".$BIAOTOU."shop (nick,uid,cid,sid,title,pic_path,created,consumer_protection,level,score,total_num,good_num,city,state,shop_click_url,`type`,`addtime`,item_score,service_score,delivery_score,fanxianlv,good) values ('".$sellernick."','".$uid."','".$Result_shop['cid']."','".$sid."','".$shoptitle."','".$shoppic."','".$Result_shop['created']."','".$Result_users["consumer_protection"]."','".$Result_users["seller_credit"]["level"]."','".$Result_users["seller_credit"]["score"]."','".$Result_users["seller_credit"]["total_num"]."','".$Result_users["seller_credit"]["good_num"]."','".$Result_users["location"]["city"]."','".$Result_users["location"]["state"]."','".$shop_click_url."','".$Result_users["type"]."',".time().",'".$Result_shop["shop_score"]["item_score"]."','".$Result_shop["shop_score"]["service_score"]."','".$Result_shop["shop_score"]["delivery_score"]."','".$Result_shopcomm."','".$good."')";
	}
}else{
	while ($row = mysql_fetch_array($rsnum))
	{
		$sid=$row['sid'];
		//if($uid==''){$uid=$row['uid'];}
		$shoptype=$row['type'];
		$shoptitle=$row['title'];
		$item_score=$row['item_score'];
		$service_score=$row['service_score'];
		$delivery_score=$row['delivery_score'];
		$shop_click_url=$row['shop_click_url'];
		$usernick=$row['nick'];
		$shoplevel=$row['level'];
		$consumer_protection=$row['consumer_protection'];
		$shopstate=$row['state'];
		$shopcity=$row['city'];
		$shoppic=$row['pic_path'];
		$fanxianlv=$row['fanxianlv'];
		$shopcreated=$row['created'];
	}
}
mysql_query($sql);
if($fanxianlv==""){
	$fanxianlv=round($CommData['taobaoke_items']['taobaoke_item']['commission']/$price*100,2);
}
$fanxianlv=ck_fxje($fanxianlv,$_SESSION["dduserlevel"]);

//热卖商品
$TaobaokeParam['method'] = 'taobao.taobaoke.items.get';
$TaobaokeParam['fields'] = 'iid,num_iid,title,nick,pic_url,price,click_url,shop_click_url,commission,commission_rate,commission_num,commission_volume,volume';
$TaobaokeParam['nick'] = MYUSERNICK;
$TaobaokeParam['cid']=$cid;
$TaobaokeParam['start_credit']='1crown';
$TaobaokeParam['end_credit']='5goldencrown';
$TaobaokeParam['start_price']='20';
$TaobaokeParam['end_price']='5000';
$TaobaokeParam['sort']='commissionNum_desc';
$TaobaokeParam['page_no']='1';
$TaobaokeParam['page_size']='6';
$TaobaokeParam['outer_code'] = $_SESSION['dduserid'];
$Taoapi->setUserParam($TaobaokeParam);
$TaobaokeData2 = $Taoapi->Send('get','xml')->getArrayData();
$ListHot = $TaobaokeData2["taobaoke_items"]["taobaoke_item"];

$page=$_GET['page'];
if($page==''){$page=1;}

$plurl="http://rate.taobao.com/detail_rate.htm?userNumId=".$uid."&auctionNumId=".$iid."&showContent=2&currentPage=".$page."&ismore=1&siteID=7";

$pagesize=20;
$totalpj=100;
include_once 'comm/wjt.php';
$tag="list";
//引入模版文件
include 'template/'.MOBAN.'/view.tpl.php';
mysql_close($cfg_link);
?>